<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html>
<head>
	<title>个人中心</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link type="text/css" rel="stylesheet" href="css/bootstrap.css">
	<link type="text/css" rel="stylesheet" href="css/style.css">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/simpleCart.min.js"></script>
	<script src="js/jquery-1.8.3.js"></script>
</head>
<body>
<script>
	function logout(id) {
		let flag = confirm("确定要注销吗?");
		if(flag){
			alert("id是: " + id);
			$.ajax({
				type:"POST",
				url:"/LogoutServlet",
				data:"id=" + id,
				dataType:"json",
				success: callBack,
				error:function () {
					alert("请求失败");
				}
			});
			function callBack (msg) {
				if (msg.result == "失败"){
					alert("注销失败");
				}else{
				 	alert("注销成功");
				}
			};
		}
	}
</script>

	<jsp:include page="header.jsp">
		<jsp:param value="4" name="flag"/>
	</jsp:include>
	<c:if test="${empty user}"><%response.sendRedirect("/index");%></c:if>
	<!--account-->
	<div class="account">
		<div class="container">
			<div class="register">
				<c:if test="${!empty msg }">
					<div class="alert alert-success">${msg }</div>
				</c:if>
				<c:if test="${!empty failMsg }">
					<div class="alert alert-danger">${failMsg }</div>
				</c:if>
				
					<div class="register-top-grid">
						<h3>个人中心</h3>
						<form action="/UserServlet?opr=changeaddress" method="post">
						<!-- 收货信息 start -->
						<h4>收货信息</h4>
							<input style="float: right" type="button" value="注销账号" href="javascript:void(0)"onclick="logout(${user.id})">
							<%--<a href="javascript:void(0)" onclick="logout(${user.id})">注销</a>--%>
						<div class="input">
							<span>收货人<label></label></span>
							<input type="text" name="name" value="${user.name }" placeholder="请输入收货"> 
						</div>
						<div class="input">
							<span>收货电话</span>
							<input type="text" name="phone" value="${user.phone }" placeholder="请输入收货电话"> 
						</div>
						<div class="input">
							<span>收货地址</span>
							<input type="text" name="address" value="${user.address }" placeholder="请输入收货地址"> 
						</div>
						<div class="register-but text-center">
						   <input type="submit" value="提交">

						</div>

							<!-- 收货信息 end -->
						</form>
						<div class="register-but text-center">
							<input id="xiu" type="submit" value="修改信息">
						</div>
						<hr>
						<form id="mi" action="/UserServlet?opr=changepwd" method="post" hidden>
						<h4>安全信息</h4>
						<div class="input">
							<span>原密码</span>
							<input type="text" name="password" placeholder="请输入原密码"> 
						</div>
						<div class="input">
							<span>新密码</span>
							<input type="text" name="newPassword" placeholder="请输入新密码"> 
						</div>
						<div class="clearfix"> </div>
						<div class="register-but text-center">
						   <input type="submit" value="提交">
						</div>	
						</form>
					</div>
				
				<div class="clearfix"> </div>
			</div>
	    </div>
	</div>
	<!--//account-->

	


	<jsp:include page="footer.jsp"></jsp:include>
<script>
	$("#xiu").click(
		function a() {
			$("#mi").toggle();
		}
	)

</script>
	
</body>
</html>